
//
//  BKMain_SimplePicCell.m
//  bestkeep
//
//  Created by utouu666 on 17/2/22.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BKMain_SimplePicCell.h"
#import "BKMainCommon.h"
#import "Mediator+BKMain.h"


@interface BKMain_SimplePicCell()
@property(nonatomic,assign)NSInteger index;

@end
@implementation BKMain_SimplePicCell

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self initView];
    }
    return self;
}

-(void)initView{
    _goodsImageView = [UIImageView new];
    _goodsImageView.userInteractionEnabled = YES;
    [self addSubview:_goodsImageView];
    [_goodsImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left);
        make.right.mas_equalTo(self.mas_right);
        make.top.mas_equalTo(self.mas_top);
        make.bottom.mas_equalTo(self.mas_bottom);
    }];
    
}
-(void)pushToFeaturedVC{
    BKMainViewController *mainPage  = (BKMainViewController *)self.nextResponder.nextResponder.nextResponder;
    Mediator *mediator = [Mediator sharedInstance];
    UIViewController *featuredVC = [mediator BKFeaturedViewController];
    featuredVC.hidesBottomBarWhenPushed = YES;
    featuredVC.view.backgroundColor = [UIColor whiteColor];
    [mainPage.navigationController pushViewController:featuredVC animated:YES];
}
- (void)fillData:(id)data{
    NSString *str = data;
    NSInteger index = [str integerValue];
    self.index = index;
    switch (index) {
        case 0:
            _goodsImageView.image = [UIImage imageNamed:@"BKFeatured_jingxuan"];
            break;
        case 1:
            _goodsImageView.image = [UIImage imageNamed:@"BKMain_国内商品"];
            break;
        default:
            _goodsImageView.image = [UIImage imageNamed:@"BKMain_全球热卖"];
            break;
    }
    
    if (self.index == 0) {
        UITapGestureRecognizer *selectFeaturedTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(pushToFeaturedVC)];
        [_goodsImageView addGestureRecognizer:selectFeaturedTap];
    }

    
}

@end
